package ink.metoo.gude.module.security.util

import ink.metoo.gude.module.security.domain.SimpleUserDetails
import ink.metoo.gude.module.security.domain.ddl.User
import org.springframework.security.core.Authentication
import org.springframework.security.core.userdetails.UserDetails
import java.security.Principal


val Authentication?.simpleUserDetails: SimpleUserDetails?
    get() = this?.principal.let { it as? SimpleUserDetails }


val Principal?.simpleUserDetails: SimpleUserDetails?
    get() = this?.let { it as? Authentication }.simpleUserDetails

val UserDetails?.original: User?
    get() = this?.let { it as? SimpleUserDetails }?.user